package com.wfs.suanfa.lock;

import java.util.concurrent.CyclicBarrier;

/**
 * @author: wfs
 * @Date: 2021/1/6 22:23
 * @Description:
 */
public class TestCyclicBarrier {
    //限流  Guava RateLimiter
    public static void main(String[] args) {
        CyclicBarrier barrier=new CyclicBarrier(10, new Runnable() {
            @Override
            public void run() {
                System.out.println("满人发车");
            }
        });
        CyclicBarrier barrier2=new CyclicBarrier(10);
        for (int i=0;i<100;i++){
            new Thread(()->{
                try {
                    barrier.await();
                }catch (Exception e){
                    e.printStackTrace();
                }
            }).start();
        }
    }
}
